package com.fnn.controller;

import com.fnn.entity.Book;
import com.fnn.service.BookService;
import com.fnn.service.UserService;
import com.fnn.util.CaptchaUtil;
import com.fnn.util.Hash256Util;
import com.google.gson.Gson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Controller
@RequestMapping(value = ("/content"),produces = "application/json;charset=UTF-8")
public class contentController {
    CaptchaUtil captchaUtil = new CaptchaUtil();

    @Autowired
    private BookService bookService;


    private Hash256Util hash256Util;


    @GetMapping("/xinshu")
    @ResponseBody
    public String getNewBook(HttpServletRequest req, HttpServletResponse resp){
        List<Book> books=bookService.selectNewBook();
        System.out.println(books);
        req.setAttribute("newBooks",books);
        Gson gson = new Gson();
        String json = gson.toJson(books);
        return json;
    }







    @RequestMapping("/XinShuTuiJian")
    public String XinShuTuiJian(){
        return "/content/XinShuTuiJian";
    }
    @RequestMapping("/TuShuLieBiao")
    public String TuShuLieBiao(){
        return "/content/TuShuLieBiao";
    }
    @RequestMapping("/DangQianJieYue")
    public String DangQianJieYue(){return "/content/DangQianJieYue";}
    @RequestMapping("/JieYueJiLu")
    public String JieYueJiLu(){
        return "/content/JieYueJiLu";
    }
    @RequestMapping("/GongNengLieBiao")
    public String GongNengLieBiao(){
        return "/content/GongNengLieBiao";
    }

}